const http = require('./http.js');
const md5 = require('./md5.js');

//发送短信 
function short(){
  var token = wx.getStorageSync('token')
  var phone = wx.getStorageSync('phoneMsg')
  var data = {
    method: 'Note.send',
    token: token,
    telephone: phone
  }
  var arr = http.sorts(data)
  data.sign = md5.hex_md5(arr)
  // console.log(arr)
  http._post(data, res => { 
      console.log(res)
      wx.showToast({
      title: res.data.msg,
      icon:'none',
      duration:1000
  }) })
}

//图片上传(更新头像)
function head(){
  var token = wx.getStorageSync('token')
  var data = {
    method: 'User.head_portrait',
    token: token,
    type: 5,
  }
  var arr = http.sorts(data)
  data.sign = md5.hex_md5(arr)
  http._post(data, res => { console.log(res) })
}

// 更新昵称
function nick_name() {
  var token = wx.getStorageSync('token')
  var nickname = wx.getStorageSync('nickname')
  var data = {
    method:'User.nickname',
    token:token,
    nickname: nickname
  }
  var arr = http.sorts(data)
  data.sign = md5.hex_md5(arr)
  http._post(data, res => { console.log(res)
      wx.showToast({
          title: res.data.msg,
          icon: 'none',
          duration: 1000
      }) }) 
}

// 钱包主页面
function wallet() {
  var token = wx.getStorageSync('token')
  var data = {
    method: 'Wallet.index',
    token: token,
  }
  var arr = http.sorts(data)
  data.sign = md5.hex_md5(arr)
  http._post(data, res => { 
    console.log(res)
        return res 
    }) 
}





















module.exports = {
  short,
  head,
  nick_name,
  wallet
}